package com.wh.typeLock;

import java.util.concurrent.locks.ReentrantLock;

/**
 * 可重入锁----synchronized
 */
public class LockDemo1 {
    public static void main(String[] args) {
        Phone phone = new Phone();
        new Thread(()->{
            phone.sendSms();
        },"A").start();
        new Thread(()->{
            phone.sendSms();
        },"B").start();

    }
}
class Phone{
    public synchronized void sendSms(){
        System.out.println(Thread.currentThread().getName()+"-->Sms");
        call(); //这里也有锁
    }

    public synchronized void call(){
        System.out.println(Thread.currentThread().getName()+"-->call");
    }
}